//
//  LoginBaseViewController.m
//  Project_IOS
//
//  Created by Jeff on 2022/1/11.
//

#import "LoginBaseViewController.h"
//#import "IQKeyboardManager.h"
#import "Color.h"
#import <Masonry/Masonry.h>
@interface LoginBaseViewController ()


@property (nonatomic, strong) UILabel *titleLb;

@end

@implementation LoginBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [Color colorWithHexString:@"#F7F7F7"];
    self.contentBgView.image = [UIImage imageNamed:@"cloud_photo_bg"];
    [self.view addSubview:self.contentBgView];
    [self.view addSubview:self.contentView];
    
    [self.contentView addSubview:self.titleLb];
    
    [self.view addSubview:self.closeBtn];
    [self.closeBtn setContentEdgeInsets:UIEdgeInsetsMake(12, 0, 12, 24)];
    [self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        if (@available(iOS 11.0, *)) {
            make.top.mas_equalTo(self.view.mas_safeAreaLayoutGuideTop).offset(10);
        } else {
            // Fallback on earlier versions
            make.top.mas_equalTo(30);
        }
        make.width.height.mas_equalTo(44);
    }];
    
//    shouldResignOnTouchOutside
    
}

-(void)dismiss {
    if (self.navigationController.presentingViewController != nil) {
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
    }else {
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
}

-(void)back {
    NSArray *viewControllers = self.navigationController.viewControllers;
    if (viewControllers.count > 1) {
        //push
        [self.navigationController popViewControllerAnimated:YES];
    } else if (self.navigationController.presentingViewController != nil) {
        //pop
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
    }
}

- (void)setTitleStr:(NSString *)titleStr {
    _titleStr = titleStr;
    self.titleLb.text = titleStr;
}



//MARK: - lazy

- (UIButton *)closeBtn {
    if (!_closeBtn) {
        _closeBtn = [UIButton buttonWithType: UIButtonTypeCustom];
        [_closeBtn setImage:[UIImage imageNamed:@"arrow_left"] forState:UIControlStateNormal];
        [_closeBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    }
    return _closeBtn;
}

- (UIView *)contentView {
    if (!_contentView) {
        _contentView = [[UIView alloc] init];
        _contentView.frame = CGRectMake(16, 137, 343, 500);
        _contentView.layer.cornerRadius = 15;
        _contentView.layer.masksToBounds = true;
        _contentView.backgroundColor = UIColor.whiteColor;
    }
    return _contentView;
}

- (UILabel *)titleLb {
    if (!_titleLb) {
        _titleLb = [[UILabel alloc] initWithFrame:CGRectMake(16, 40, 343-32, 33)];
        _titleLb.textColor = [Color colorWithHexString:@"#333333"];
        _titleLb.font = [UIFont boldSystemFontOfSize:24];
        _titleLb.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLb;
}

- (BlueButtonView *)buttonView {
    if (!_buttonView) {
        _buttonView = [[BlueButtonView alloc] init];
    }
    return _buttonView;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
